package com.bdqn.ch05.SL;

import com.bdqn.ch05.SL.mapper.Ink;
import com.bdqn.ch05.SL.mapper.Paper;

/**
 * Printer
 * 打印机程序
 * 面向接口编程，而不是具体的实现类
 * @aurhor Administrator  whs
 * @since 2024/7/10
 */
public class Printer {

    private Ink ink = null;
    private Paper paper = null;

    /**
     * 打印方法
     * @param massage 要打印的内容
     */
    public void print(String massage){
        //输出颜色标记
        System.out.println("使用"+ink.getColor(255,200,0)+"颜色打印：\n");
        // 逐字符输出到纸张
        for (int i = 0; i < massage.length(); ++i) {
            paper.putInChar(massage.charAt(i));
        }
        //将纸张的内容输出
        System.out.println(paper.getContent());
    }

    /**
     * 设置注入所需的setter方法
     * @param ink
     */
    public void setInk(Ink ink) {
        this.ink = ink;
    }

    /**
     * 设置注入所需的setter方法
     * @param paper
     */
    public void setPaper(Paper paper) {
        this.paper = paper;
    }


}
